package com.chinaisafe.user.dto;

import com.chinaisafe.user.entity.SysAccount;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * SysAccountDTO
 * Description：账号数据传输对象
 *
 * @author xuefu.shu
 * @date  2024-07-12 09:55:54
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysAccountDTO", description = "账号数据传输对象")
public class SysAccountDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    private Long id;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "登录账号")
    private String account;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "微信openid")
    private String wxOpenid;

    @Schema(description = "用户类别")
    private Integer userType;

    @Schema(description = "主租户")
    private String mainTenantCode;


    /**
     * 将实体类转换为数据传输对象
     * @param entity 实体对象
     * @return SysAccountDTO 数据传输对象
     * @author xuefu.shu
     * @date 2024-07-12 09:55:54
     */
    public static SysAccountDTO convertFromEntity(SysAccount entity) {
        SysAccountDTO dto = new SysAccountDTO();
        dto.id = entity.getId();
        // 给对应的字段赋值 可根据实际业务删减
        dto.mobile = entity.getMobile();
        dto.password = entity.getPassword();
        dto.wxOpenid = entity.getWxOpenid();
        dto.userType = entity.getUserType();
        dto.mainTenantCode = entity.getMainTenantCode();
        return dto;
    }
}
